package com.deryun.tyl.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.deryun.tyl.bean.News;
import com.deryun.tyl.dao.impl.NewsDaoImpl;

@Service("newsServiceImpl")
public class NewsServiceImpl {
	
	@Resource(name = "newsDaoImpl")
	private NewsDaoImpl newsDaoImpl;
	
	public List<News> getAllNews(){
		return newsDaoImpl.getAllNews();
	}
	
	
	public int addNews(News news){
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		news.setPublishDate(df.format(new Date()));
		return newsDaoImpl.addNews(news);
	}
	
	
	public int deleteNews(int id){
		return newsDaoImpl.deleteNews(id);
		
	}
}
